package java19_5_11.udp.dictionary_service;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class Client {
    public static void main(String[] args) throws IOException {
        // 目前服务器在本机: 127.0.0.1
        // 目前服务器的端口是: 8080

        // 目前只发送一次请求
        String word = "apple";

        // 准备发送请求
        String request = "我是Java19班的\r\n" + word + "\r\n";

        byte[] bytes = request.getBytes("UTF-8");
        DatagramPacket sent = new DatagramPacket(
                bytes,
                0,
                bytes.length,
                InetAddress.getLoopbackAddress(),
                8080
        );
        DatagramSocket socket = new DatagramSocket(9999);
        socket.send(sent);
    }
}
